package com.bw.parkingspace_module.parkingedit

import com.bw.parkingspace_module.parkingedit.entity.*
import com.kf.common.entity.BaseEntity
import com.kf.common.mvi.model.BaseModel
import com.kf.lib_network.retrofit.HttpType
import com.kf.lib_network.retrofit.RetrofitFactory
import kotlinx.coroutines.flow.Flow
import okhttp3.MultipartBody

class ParkingEditModel : BaseModel() {

    fun requestColor(): Flow<BaseEntity<List<ColorEntity>>> {
        return RetrofitFactory()
            .createRetrofit(HttpType.TOKEN)
            .create(ApiService::class.java)
            .requestColor()
    }

    fun requestCar(map: HashMap<String, Any>): Flow<BaseEntity<CarEntity>> {
        return RetrofitFactory()
            .createRetrofit(HttpType.TOKEN)
            .create(ApiService::class.java)
            .requestCar(createBody(map))
    }

    fun requestDept(map: HashMap<String, Any>): Flow<BaseEntity<List<DeptEntity>>> {
        return RetrofitFactory()
            .createRetrofit(HttpType.NONE)
            .create(ApiService::class.java)
            .requestDept(createBody(map))
    }

    fun requestCarImage(map: HashMap<String, Any>): Flow<BaseEntity<ImageEntity>> {
        return RetrofitFactory()
            .createRetrofit(HttpType.TOKEN)
            .create(ApiService::class.java)
            .requestCarImage(createBody(map))
    }

    fun requestPaakingEdit(map: HashMap<String, Any>): Flow<BaseEntity<ParkingEditEntity>> {
        return RetrofitFactory()
            .createRetrofit(HttpType.TOKEN)
            .create(ApiService::class.java)
            .requestParkingEdit(createBody(map))
    }

    fun upLoadCarImg(part: MutableList<MultipartBody.Part>) :Flow<BaseEntity<LoadImgEntity>>{
        return RetrofitFactory().createRetrofit(HttpType.NONE)
            .create(ApiService::class.java)
            .upLoadCarImg(part)
    }

}